package com.imooc.ecommerce.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * 用户订单表实体类定义
 * @author zhangshao
 * @since 2023/12/13 22:55
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName("t_ecommerce_order")
public class EcommerceOrder {

    /**
     * 自增主键
     */
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 用户id
     */
    @TableField(value = "user_id")
    private Long userId;

    /**
     * 地址id
     */
    @TableField(value = "address_id")
    private Long addressId;

    @TableField(value = "order_detail")
    private String orderDetail;

    /**
     * 创建时间
     */
    @TableField(value = "create_time",fill= FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
    private Date createTime;

    /**
     * 更新时间
     */
    @TableField(value = "update_time",fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
    private Date updateTime;


    public EcommerceOrder(Long userId, Long addressId, String orderDetail) {
        this.userId = userId;
        this.addressId = addressId;
        this.orderDetail = orderDetail;
    }
}
